package com.auto.learning.activity;

import java.util.ArrayList;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.auto.learning.R;
import com.auto.learning.adapter.TabViewPagerAdapter;
import com.auto.learning.fragment.SmoothBookListFragment;
import com.auto.learning.fragment.SmoothFragment;
import com.auto.learning.view.SharedPreferencesUtils;
import com.auto.learning.view.SlidingTabLayout;

public class SmoothActivity extends FragmentActivity {
	
	private SlidingTabLayout smooth_sliding_tabs;
	private ViewPager viewPager;
	private ArrayList<Fragment> fragmentArrayList = new ArrayList<Fragment>();
	private String mTabTitle[] = new String[]{""};
	private int[] imageUrls = {}; 
	
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.smooth_activity);
		initView();
	}
	
	private void initView(){
		SharedPreferencesUtils.setParam(this, "isFirst", false);
		for (int i = 0; i < mTabTitle.length; i++) {
			if (i < imageUrls.length) {
				SmoothFragment smoothFragment = new SmoothFragment();
				smoothFragment.setResId(imageUrls[i]);
				fragmentArrayList.add(smoothFragment);
			}else {
				fragmentArrayList.add(new SmoothBookListFragment());
			}
		}
		smooth_sliding_tabs = (SlidingTabLayout) findViewById(R.id.smooth_sliding_tabs);
		smooth_sliding_tabs.setVisibility(View.GONE);
		TabViewPagerAdapter adapter = new TabViewPagerAdapter(getSupportFragmentManager(), this, fragmentArrayList, mTabTitle);
		viewPager = (ViewPager) findViewById(R.id.viewpager);
		viewPager.setOffscreenPageLimit(mTabTitle.length);
	    viewPager.setAdapter(adapter);
	    smooth_sliding_tabs = (SlidingTabLayout) findViewById(R.id.smooth_sliding_tabs);
	    smooth_sliding_tabs.setCustomTabView(R.layout.tab_text, R.id.tv_tab_content,R.color.main_green_color,R.color.main_grake_color);
	    smooth_sliding_tabs.setDistributeEvenly(true);
	    smooth_sliding_tabs.setViewPager(viewPager);
	    smooth_sliding_tabs.setSelectedIndicatorColors(getResources().getColor(R.color.black));
	    smooth_sliding_tabs.setBackgroundColor(getResources().getColor(R.color.black));
	}
	
	
}
